﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace LDCRNewEdit.Model
{
    public class SceneBuildLv : System.IComparable, ICloneable 
    {

        public byte Level { get; set; }
        public byte PlayMode { get; set; }
        public byte FrameNum { get; set; }
        public short FrameDelay { get; set; }
        public short KeyPointX { get; set; }
        public short KeyPointY { get; set; }
        public short X { get; set; }
        public short Y { get; set; }
        //public string Path { get { return _path; } set { _path = value; _image = Image.FromFile(value); W = (short)_image.Width; H = (short)_image.Height; } }
        public string Path { get; set; }
        public Image Image { get; set; }

        public short W { get; set; }
        public short H { get; set; }


        public int CompareTo(object obj)
        {
            if (!(obj is SceneBuildLv))
                throw new InvalidCastException("This object is not of type SceneBuildLv");
            SceneBuildLv sl = (SceneBuildLv)obj;

            if (sl.Level > this.Level)
            {
                return -1;
            }
            else if (sl.Level < this.Level)
            {
                return 1;
            }
            else
            {
                int tv = this.KeyPointX + this.KeyPointY + this.X + this.Y;
                int ov = sl.KeyPointX + sl.KeyPointY + sl.X + sl.Y;

                return tv.CompareTo(ov);
            }
        }

        public object Clone()
        {
            return this.MemberwiseClone();
        } 
    }
}
